home *** CD-ROM | disk | FTP | other *** search
/ Univers Mac Interactif 52 / Univers Mac Interactif - Issue 52.iso / JOURNAUX / csmp-digest-v3-114 1⁄4 < prev    next >
Text File  |  1995-11-13  |  76KB  |  2,052 lines

  1. C.S.M.P. Digest             Fri, 29 Sep 95       Volume 3 : Issue 114
  2.  
  3. Today's Topics:
  4.  
  5.         Balloon help in modeless dialog???
  6.         Determining your ports
  7.         Disable Shift startup?
  8.         Error Strings in Resource file?
  9.         How do I change the mouse tracking speed?
  10.         How to disable entire menu bar?
  11.         How to do continuous sound recording
  12.         How to receive an "open" message...
  13.         Mac game programming web page
  14.         Patching _Launch redux
  15.         Pathname generation code?
  16.         Three AppleScript Qs (Apple Events)
  17.  
  18.  
  19.  
  20. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  21. (pottier@clipper.ens.fr).
  22.  
  23. The digest is a collection of article threads from the internet newsgroups
  24. comp.sys.mac.programmer.help, csmp.tools and csmp.misc. It is designed for
  25. people who read news semi-regularly and want an archive of the discussions.
  26. If you don't know what a newsgroup is, you probably don't have access to
  27. it. Ask your systems administrator(s) for details. If you don't have access
  28. to news, you may still be able to post messages to the group by using a
  29. mail server like anon.penet.fi (mail help@anon.penet.fi for more
  30. information).
  31.  
  32. Each issue of the digest contains one or more sets of articles (called
  33. threads), with each set corresponding to a 'discussion' of a particular
  34. subject.  The articles are not edited; all articles included in this digest
  35. are in their original posted form (as received by our news server at
  36. nef.ens.fr).  Article threads are not added to the digest until the last
  37. article added to the thread is at least two weeks old (this is to ensure that
  38. the thread is dead before adding it to the digest).  Article threads that
  39. consist of only one message are generally not included in the digest.
  40.  
  41. The digest is officially distributed by two means, by email and ftp.
  42.  
  43. If you want to receive the digest by mail, send email to listserv@ens.fr
  44. with no subject and one of the following commands as body:
  45.     help                                Sends you a summary of commands
  46.     subscribe csmp-digest Your Name     Adds you to the mailing list
  47.     signoff csmp-digest                 Removes you from the list
  48. Once you have subscribed, you will automatically receive each new
  49. issue as it is created.
  50.  
  51. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  52. Questions related to the ftp site should be directed to
  53. scott.silver@dartmouth.edu.
  54.  
  55. -------------------------------------------------------
  56.  
  57. >From reed@medicine.wustl.edu (Thomas Reed)
  58. Subject: Balloon help in modeless dialog???
  59. Date: Wed, 13 Sep 1995 08:36:29 -0500
  60. Organization: Washington University
  61.  
  62. I've got a program that had a modal options dialog, and I just tried
  63. modifying the code to make it into a modeless dialog.  Everything is
  64. working but one thing -- the balloon help I had set up for the dialog no
  65. longer works.
  66.  
  67. How do I get my 'hdlg' items to work in a modeless dialog?
  68.  
  69. Thanks in advance!
  70.  
  71. -Thomas
  72.  
  73. =====================================================
  74. Thomas Reed                     Washington University
  75. reed@visar.wustl.edu               Medical School
  76. reed@medicine.wustl.edu            Saint Louis, MO
  77. http://medinfo.wustl.edu/~reed
  78. - ---------------------------------------------------
  79. Clothes make the man.  Naked people have little or no
  80. influence on society.  -- Mark Twain
  81. =====================================================
  82.  
  83. Opinions posted are not the opinions of Wash. U.
  84.  
  85. +++++++++++++++++++++++++++
  86.  
  87. >From rdwells@mmm.com (Richard Wells)
  88. Date: 14 Sep 1995 18:01:49 GMT
  89. Organization: 3M Company
  90.  
  91. reed@medicine.wustl.edu (Thomas Reed) wrote:
  92. >I've got a program that had a modal options dialog, and I just tried
  93. >modifying the code to make it into a modeless dialog.  Everything is
  94. >working but one thing -- the balloon help I had set up for the dialog no
  95. >longer works.
  96. >
  97. >How do I get my 'hdlg' items to work in a modeless dialog?
  98.  
  99. I'm not positive this will help, but Apple's tech note TB 34
  100. discusses the use of the Help Manager with movable modal
  101. dialogs.  I suspect that the same concerns apply to modeless
  102. dialogs.
  103.  
  104.  
  105.  
  106. +++++++++++++++++++++++++++
  107.  
  108. >From resorcerer@aol.com (Resorcerer)
  109. Date: 15 Sep 1995 04:04:17 -0400
  110. Organization: America Online, Inc. (1-800-827-6364)
  111.  
  112. You have to use an 'hwin' (a list of windows by title or windowKind) to
  113. attach any 'hdlg' or 'hrct' messages to the non-modal dialog's itemlist.
  114.  
  115. It sucks, but DialogSelect/IsDialogEvent don't support balloons the way
  116. you'd expect (and the way it's documented in NIM).  It sucks worse if
  117. you're non-modal windows have dynamic names.
  118.  
  119. Trust me on this; when I was adding balloons to Resorcerer's own windows
  120. (nearly all of which are non-modal dialogs), it took me
  121. months of trying to figure out why the help didn't show up.  Finally
  122. an Apple DTS engineer (help that did show up :) and I sat down and pinned
  123. the thing down.
  124.  
  125. All of which is why Resorcerer will alerts you to this problem when you
  126. create an 'hdlg' for a moveable modal dialog window.
  127.  
  128. Doug McKenna
  129. Mathemaesthetics, Inc.
  130. Developers of Resorcerer
  131.  
  132. ---------------------------
  133.  
  134. >From dunham@nw.pensee.com (David Dunham)
  135. Subject: Determining your ports
  136. Date: Mon, 25 Sep 1995 14:18:21 -0700
  137. Organization: Pensee Corporation
  138.  
  139. I'm sure I will find this as soon as I post, but so far I haven't found
  140. any code or Gestalt attributes or whatever to determine what sort of
  141. serial ports a Mac has. Notably, does it have a Printer/Modem port instead
  142. of two separate ports?
  143.  
  144. (The MacOS SDK has Comm Toolbox files, but no documentation.)
  145.  
  146. David Dunham   Pensee Corporation   dunham@nw.pensee.com
  147. Voice/Fax 206 783 7404              http://www.pensee.com/dunham/
  148.     "I say we should listen to the customers and give them what they want."
  149.     "What they want is better products for free." --Scott Adams
  150.  
  151. +++++++++++++++++++++++++++
  152.  
  153. >From oster@netcom.com (David Phillip Oster)
  154. Date: Thu, 28 Sep 1995 18:02:04 GMT
  155. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  156.  
  157. In article <dunham-2509951418210001@feather.pensee.com> dunham@nw.pensee.com (David Dunham) writes:
  158. >I'm sure I will find this as soon as I post, but so far I haven't found
  159. >any code or Gestalt attributes or whatever to determine what sort of
  160. >serial ports a Mac has. Notably, does it have a Printer/Modem port instead
  161. >of two separate ports?
  162.  
  163. Are you the David Dunham who wrote the original "Acta"? I've been a fan
  164. of your work for years.  Here is small complete program that is an example
  165. of using the Communications Resource Manager to determine what serial ports
  166. exist on a specific machine:
  167.  
  168. /* main.c - Using Connection Resource Manager, print all the portnames.
  169.         Public domain. By David Phillip Oster
  170.  */
  171. #include <stdio.h>
  172. #include <CRMSerialDevices.h>
  173. #include <CommResources.h>
  174.  
  175. #define Length(s)       ((int) (s)[0])
  176.  
  177. main()
  178. {
  179.         CRMRecPtr               crp;
  180.         CRMRec                  crm;
  181.         CRMSerialPtr    csp;
  182.         StringPtr               s;
  183.         FILE                    *out;
  184.  
  185.         InitCRM();
  186.  
  187.         crm.qLink = NULL;
  188.         crm.qType = crmType;
  189.         crm.crmVersion = crmRecVersion;
  190.         crm.crmPrivate = 0;
  191.         crm.crmReserved = 0;
  192.         crm.crmDeviceType = crmSerialDevice;
  193.         crm.crmDeviceID = 0;
  194.         crm.crmAttributes = 0;
  195.         crm.crmStatus = 0;
  196.         crm.crmRefCon = 0;
  197.         crp = &crm;
  198.         if(NULL == (out = fopen("log", "w"))){
  199.                 return -1;
  200.         }
  201.         while(NULL != (crp = CRMSearch(crp))){
  202.                 if(NULL != (csp = (CRMSerialPtr) crp->crmAttributes)){
  203.                         if(NULL != (s = *csp->inputDriverName)){
  204.                                 fprintf(out, "\"%.*s\"\n", Length(s), &s[1]);
  205.                         }
  206.                         if(NULL != (s = *csp->outputDriverName)){
  207.                                 fprintf(out, "\"%.*s\"\n", Length(s), &s[1]);
  208.                         }
  209.                 }
  210.         }
  211.         return 0;
  212. -- 
  213. - ------- <mail-to:oster@netcom.com> ----------
  214. Ahh! The thorazine is wearing off and the odinazine is coming on...
  215.  
  216. +++++++++++++++++++++++++++
  217.  
  218. >From Alex Rosen <alex@procd.com>
  219. Date: 28 Sep 1995 18:42:53 GMT
  220. Organization: Pro CD, Inc.
  221.  
  222. In article <dunham-2509951418210001@feather.pensee.com> David Dunham,
  223. dunham@nw.pensee.com writes:
  224. >I'm sure I will find this as soon as I post, but so far I haven't found
  225. >any code or Gestalt attributes or whatever to determine what sort of
  226. >serial ports a Mac has. Notably, does it have a Printer/Modem port instead
  227. >of two separate ports?
  228.  
  229. Here are a couple of threads I saved from a while ago that might help.
  230. --Alex
  231.  
  232.  
  233.  
  234.  
  235. - ---------------------------------------------------------------------
  236. - -
  237. Path: sundog.tiac.net!news.kei.com!news.mathworks.com!udel!delmarva.com  
  238.  !newsfeed.internetmci.com!news.silcom.com!usenet
  239. From: David Shortt <wyatt@wyatt.com>
  240. Newsgroups: comp.sys.mac.programmer.misc
  241. Subject: Re: Serial Ports Communication
  242. Date: 14 Jun 1995 05:36:20 GMT
  243.  
  244. ted@sophocles.algonet.se (Ted Parnefors) wrote:
  245. >I was hoping someone could had the answer to how i can find the device
  246. >name of a port, when opening it with  OpenDevice, from what i've read
  247. >in "inside macintosh" the serial port is "AIn" and "AOut" and the parallell
  248. >port is "BIn" and "BOut", but how do  i know the name if i plug in a 
  249. >serial port card or user the program portshare over a network ?
  250. >Anyone has any ideas? or is this not a good way of using serial communication
  251. >on the Macintosh? I heard something about using Communication Toolbox,
  252. >but haven't found any info on it, so i guess i'm stuck.
  253. >Thanks in advance,
  254. >
  255. >Ted
  256. >
  257.  
  258. Some kind soul provided this code example some time ago.  I've tweaked
  259. it to work on THINK Pascal, but you should be able to see the gist of
  260. it:
  261.  
  262. - -------------------------------
  263. program test;
  264.  
  265.     uses
  266.         CommResources, CRMSerialDevices;
  267.  
  268.     var
  269.         crm: CRMRec;
  270.         crp: CRMRecPtr;
  271.         csp: CRMSerialPtr;
  272.         s: StringHandle;
  273.         myErr: OSErr;
  274.  
  275. begin
  276.     ShowText;  {tells THINK Pascal to show a default text output window}
  277.  
  278.     myErr := InitCRM;
  279.     with crm do begin
  280.         qLink := nil;
  281.         qType := crmType;
  282.         crmVersion := crmRecVersion;
  283.         crmPrivate := 0;
  284.         crmReserved := 0;
  285.         crmDeviceType := crmSerialDevice;
  286.         crmDeviceID := 0;
  287.         crmStatus := 0;
  288.         crmRefCon := 0;
  289.     end;
  290.     crp := @crm;  {get pointer to crm}
  291.  
  292.     repeat
  293.         crp := CRMRecPtr(CRMSearch(QElemPtr(crp)));
  294.         if crp <> nil then begin
  295.             csp := CRMSerialPtr(crp^.crmAttributes);
  296.             if csp <> nil then begin  {write some stuff}
  297.                 s := csp^.name;
  298.                 if s <> nil then
  299.                     writeln('name: "', s^^, '"');
  300.                 s := csp^.inputDriverName;
  301.                 if s <> nil then
  302.                     writeln('Input driver name: "', s^^, '"');
  303.                 s := csp^.outputDriverName;
  304.                 if s <> nil then
  305.                     writeln('Output driver name: "', s^^, '"');
  306.                 writeln;
  307.             end;
  308.         end;
  309.     until crp = nil;
  310.  
  311.     repeat
  312.     until button;
  313.  
  314. end.
  315. - ---------------------------------
  316.  
  317. On my Mac this program produces this output:
  318. - ---------------------------------
  319. name: "Modem Port"
  320. Input driver name: ".AIn"
  321. Output driver name: ".AOut"
  322.  
  323. name: "Printer Port"
  324. Input driver name: ".BIn"
  325. Output driver name: ".BOut"
  326. - ---------------------------------
  327.  
  328. Hope this helps.
  329.  
  330. Dave Shortt
  331. wyatt@wyatt.com
  332.  
  333.  
  334.  
  335.  
  336. From: h+@metrowerks.com (Jon Watte)
  337. Newsgroups: comp.sys.mac.programmer.misc
  338. Subject: Re: Serial Ports Communication
  339. Date: Thu, 15 Jun 1995 10:38:49 -0500
  340.  
  341. In article <3rl27i$a8l@sophocles.algonet.se>,
  342. ted@sophocles.algonet.se (Ted Parnefors) wrote:
  343.  
  344. > Anyone has any ideas? or is this not a good way of using serial communication
  345. > on the Macintosh? I heard something about using Communication Toolbox,
  346. > but haven't found any info on it, so i guess i'm stuck.
  347.  
  348. Comms Resource Manager.
  349.  
  350. comp.sys.mac.programmer FAQ: http://www.nada.kth.se/~d88-jwa/mac-faq.html
  351.  
  352. Cheers,
  353.  
  354.                                 / h+
  355.  
  356.  
  357.  
  358.  
  359.  
  360. Newsgroups: comp.lang.pascal.mac,comp.sys.mac.programmer.help
  361. Path: sundog.tiac.net!news.kei.com!news.mathworks.com!zombie.ncsc.mil   
  362. !news.duke.edu!agate!howland.reston.ans.net!ix.netcom.com!netcom.com!oster
  363. From: oster@netcom.com (David Phillip Oster)
  364. Subject: Re: Serial port names for Hurdler, LineShare, etc?
  365.  
  366. In article <oylerb-2507952346320001@msp6-8.nas.mr.net>
  367. oylerb@tdkt.skypoint.net (Bill A. Oyler) writes:
  368. >This should be a somewhat simple question: how can I retreive some sort of
  369. >"list" of installed serial ports?  
  370.  
  371. This is small sample program that uses just enough of the Connection
  372. Resource
  373. Manager to do exactly what you want. You get a record containing:
  374. the name to show the user,
  375. the inName, the outName, and an icon.
  376.  
  377. /* main.c - Using Connection Resource Manager, print all the portnames.
  378.  */
  379. #include <stdio.h>
  380. #include <CRMSerialDevices.h>
  381. #include <CommResources.h>
  382.  
  383. #define Length(s)       ((int) (s)[0])
  384.  
  385. main()
  386. {
  387.         CRMRecPtr               crp;
  388.         CRMRec                  crm;
  389.         CRMSerialPtr    csp;
  390.         StringPtr               s;
  391.         FILE                    *out;
  392.  
  393.         InitCRM();
  394.  
  395.         crm.qLink = NULL;
  396.         crm.qType = crmType;
  397.         crm.crmVersion = crmRecVersion;
  398.         crm.crmPrivate = 0;
  399.         crm.crmReserved = 0;
  400.         crm.crmDeviceType = crmSerialDevice;
  401.         crm.crmDeviceID = 0;
  402.         crm.crmAttributes = 0;
  403.         crm.crmStatus = 0;
  404.         crm.crmRefCon = 0;
  405.         crp = &crm;
  406.         if(NULL == (out = fopen("log", "w"))){
  407.                 return -1;
  408.         }
  409.         while(NULL != (crp = CRMSearch(crp))){
  410.                 if(NULL != (csp = (CRMSerialPtr) crp->crmAttributes)){
  411.                         if(NULL != (s = *csp->inputDriverName)){
  412.                                 fprintf(out, "\"%.*s\"\n", Length(s), &s[1]);
  413.                         }
  414.                         if(NULL != (s = *csp->outputDriverName)){
  415.                                 fprintf(out, "\"%.*s\"\n", Length(s), &s[1]);
  416.                         }
  417.                 }
  418.         }
  419.         return 0;
  420.  
  421. ---------------------------
  422.  
  423. >From grinch@ns.moran.com (Erik Rose)
  424. Subject: Disable Shift startup?
  425. Date: Sat, 09 Sep 1995 23:20:59 -0400
  426. Organization: Vortex Software
  427.  
  428. How can I fix an INIT so the shift key on startup won't disable it (other 
  429. than stuffing it in the System file, please)? The control panel 
  430. BootBlocker seems to accomplish this very nicely. Please help me! Do me a 
  431. favor & e-mail your replies. Thanx in advance!!
  432.  
  433. ÑThe Grinch
  434.  
  435. +++++++++++++++++++++++++++
  436.  
  437. >From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
  438. Date: Tue, 12 Sep 1995 14:57:33 +0800
  439. Organization: Underemployed, and loving it!
  440.  
  441. In article <grinch-0909952320590001@nw33.moran.com>, grinch@ns.moran.com
  442. (Erik Rose) wrote:
  443.  
  444. >How can I fix an INIT so the shift key on startup won't disable it (other 
  445. >than stuffing it in the System file, please)? The control panel 
  446. >BootBlocker seems to accomplish this very nicely. Please help me! Do me a 
  447. >favor & e-mail your replies. Thanx in advance!!
  448.  
  449. Delete the 'dbex' resource in the System file.  Alternatively make your
  450. INIT some other form of system extension (a script bundle perhaps) that
  451. gets run despite the presence of the shift key.
  452.  
  453. Share and Enjoy.
  454. --
  455. Quinn "The Eskimo!"      "That's it, take me to your secret government
  456.                           labs and cut me into wafer thin sections."
  457.  
  458. +++++++++++++++++++++++++++
  459.  
  460. >From ammon@bert.cs.byu.edu (Ammon J. Skidmore)
  461. Date: 13 Sep 1995 05:43:41 GMT
  462. Organization: Brigham Young University
  463.  
  464. Erik Rose (grinch@ns.moran.com) wrote:
  465. : How can I fix an INIT so the shift key on startup won't disable it (other 
  466. : than stuffing it in the System file, please)? The control panel 
  467. : BootBlocker seems to accomplish this very nicely. Please help me! Do me a 
  468. : favor & e-mail your replies. Thanx in advance!!
  469.  
  470. under 7.1+, if you put your INIT into a font suitcase and then put the 
  471. suitcase into the Fonts folder, it will run regardless of whether the 
  472. SHIFT key is down on startup.  No system modifications required!
  473.  
  474. -Ammon
  475.  
  476. --
  477. Ammon Skidmore       | http://bert.cs.byu.edu/~ammon/ammon.html
  478. Skidperfect Software | http://www.shore.net/~chanson
  479.                      | ftp://ftp.shore.net/members/chanson
  480.  
  481. ---------------------------
  482.  
  483. >From Peter Kjersgard <petek>
  484. Subject: Error Strings in Resource file?
  485. Date: 6 Sep 1995 19:42:22 GMT
  486. Organization: Motorola Information Systems Group; Mansfield, MA
  487.  
  488. The app I am writing has 100+ error messages to display to the user. I
  489. carefully typed them into a STR# resource for the app. Sometimes I have to
  490. add/delete in the middle of the list. Since I reference the strings by their
  491. index, I have to keep updating a separate list of defines that map to the
  492. strings. (a BIG pain!!!)
  493.  
  494. Is there a better way to reference the strings?
  495.  
  496. What are the benefits of keeping the strings in the resources fork rather than
  497. in the code itself? Is the string only loaded into memory when referenced, thus
  498. saving memory space by keeping the strings in the resource fork? Or is it
  499. simply to allow the strings to be modified without rebuilding the app?
  500.  
  501. Thanks,
  502. --Pete
  503. petek@dev.cdx.mot.com
  504.  
  505.  
  506. +++++++++++++++++++++++++++
  507.  
  508. >From kenlong@netcom.com (Ken Long)
  509. Date: Wed, 6 Sep 1995 21:49:26 GMT
  510. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  511.  
  512. Peter Kjersgard (petek) wrote:
  513. : The app I am writing has 100+ error messages to display to the user. I
  514. : carefully typed them into a STR# resource for the app. Sometimes I have to
  515. : add/delete in the middle of the list. Since I reference the strings by their
  516. : index, I have to keep updating a separate list of defines that map to the
  517. : strings. (a BIG pain!!!)
  518.  
  519. : Is there a better way to reference the strings?
  520.  
  521. I don't know about referencing, but there are easier ways of dealing with 
  522. the resource compilation, itself.
  523.  
  524. One thing, though, Think C uses a special complied resource for its error 
  525. strings.  They probably found that it *was* an easier way.  Also, it's 
  526. not as easy to mess with.
  527.  
  528. Anyway, 'STR#' resources are easy to work on with a combination of 
  529. ResTools 3.0 and McSink (I like the older McSink).
  530.  
  531. ResTools is an unsupported (the author hasn't had time for Mac's) 
  532. resource compiler/decompiler, touted as "the poor man's Rez/DeRez."  It 
  533. has it's uses and it's shortcomings.  (I usually use a program for its 
  534. uses and leave its deficiencies to some other program which excells in 
  535. those aspects.)
  536.  
  537. It decompiles 'STR#' resouces into a nice, neat list of one-liners.  If
  538. you use McSink, ResTools and a text editor with a good Find/Replace
  539. function, you can "whomp up" a 'STR#' resource - regardless of the number
  540. of entries - in a couple minutes. 
  541.  
  542. Therefore, redoing the list is equally as fast and easy, as well as 
  543. relinking code references to it.
  544.  
  545. If you select only the list of entries, in your ".r file" from within 
  546. your text editor, the copy, then open McSink, the list will be there.  
  547. Then, hit Command I (indent) and Command N (add line numbers) then 
  548. Command A (select all) Command C (duh) and close it, then Command V, you 
  549. numbered list will be back in your .r file (or wherever you put it) for 
  550. referferencing changed GetIndString (and such) calls.
  551.  
  552. Another way is use an array of Str255, right in your code, and get it 
  553. finalized and THEN make a resource out of it.  In this case, instead of 
  554. your .r file being something ResTools compiles, you make it a .c file, 
  555. and change it from a "resource 'STR#' (128, "Error Strings)" to a type
  556. "Str255[numEntries] = {".  You can make your commented-out list entry 
  557. numbers with McSink and Find/Replace.  
  558.  
  559. Copy the list EXCEPT for the first entry, open McSink, add indents if it
  560. has none, add line numbers, copy and paste into a new "worksheet" doc. 
  561. Put your first entry back at the top of the list.  Then find every tab and
  562. change it to a return-tab - there will only be the one indent (TAB) per
  563. line.  Now, find every comma-return and change it to comma-TAB-// and you
  564. have your indicator numbers. 
  565.  
  566. I think there has to be a zero entry, whereas your resource will start at
  567. #1 (?).  But, for your temporary array, you merely add a dummy 0 entry.  
  568. The tags will still be the same.
  569.  
  570. If, in developing your program, you find that you have to add an entry 
  571. mid list, just deactivate "Wrap Around" in the Find/Replace dialog, copy 
  572. the list to a worksheet, put the insertion point at the end of the added 
  573. line, write "TAB//" and give it the number of the next line, Command F, 
  574. find return, replace with space+space1return ( + 1\r) and replace all.  
  575. This will do from there on down.
  576.  
  577. This will inform you of what number to write in the GetIndString call, 
  578. without having to retag the whole list.
  579.  
  580. Later, once you have it finalized, you copy the whole array to worksheet 
  581. doc (new, empty) and preprocess.  This will strip all the comments out 
  582. and you can copy it into ResTools for compilation into the 'STR#' resource.
  583.  
  584. Then, all that you'll have left to do is change the array references in 
  585. your code to the 'STR#' references.
  586.  
  587. One more way to do it would be to use the SetIndString routine to make 
  588. your changes to the 'STR#' resource lines as you go.  Temporarily add the 
  589. calls to your code wherever you need them and nor mess with ResTools or 
  590. McSink - just have a record of what you do in an external file so you can 
  591. keep track.  Keep a copy of the needed calls which you can copy/paste 
  592. into your code as needed.  Then, each time you run your resource would be 
  593. updated.
  594.  
  595. In fact, you could make a 'STR#' resource with a predetermined number of 
  596. blank entries and just write that resource as you write your program.
  597.  
  598. SetIndString overwrites an existing line in a 'STR#' resource, but you 
  599. could modify it to add a line.
  600.  
  601. It can be found in the snippets as apple.com.
  602.  
  603. : What are the benefits of keeping the strings in the resources fork
  604. rather than : in the code itself? Is the string only loaded into memory
  605. when referenced, thus : saving memory space by keeping the strings in the
  606. resource fork? Or is it : simply to allow the strings to be modified
  607. without rebuilding the app? 
  608.  
  609. I know if you build an array you have to provide storage for all its 
  610. elements, but I don't know about what you asked.  I've seen HUGE arrays 
  611. set up in code.  Look at NewShuttle - 635 array entries, each with their 
  612. allotted type assignments.
  613.  
  614. I'd say resources are handier, once made.  When you say GetIndString and 
  615. where in RAM you're putting it (myStr?) you are overwriting what was 
  616. there (as I understand it) and the list number just points to the 
  617. resource ID and list number and it reads it on the fly.  Your next 
  618. GetIndString call stores it in the same 255, while being used and until 
  619. the next overwrite (do I have this right?).  I have some 'STR#' ID's with 
  620. as many as 150 entries.  In an array, that's 150 Str255's (is it not?).
  621.  
  622. I just checked and I was at least partly right - the rest I need to read 
  623. up on.  GetIndString does copy the tagged line into an existing area 
  624. "theString," of the call) so you are only using one Str255 at any given time.
  625.  
  626. -Ken-
  627.  
  628. +++++++++++++++++++++++++++
  629.  
  630. >From tulip@tiac.net (Ed Anson)
  631. Date: Wed, 06 Sep 1995 20:36:54 -0400
  632. Organization: Tulip Software
  633.  
  634. In article <42ktiu$k4d@prospero.dev.cdx.mot.com>, Peter Kjersgard <petek> wrote:
  635.  
  636. > The app I am writing has 100+ error messages to display to the user. I
  637. > carefully typed them into a STR# resource for the app. Sometimes I have to
  638. > add/delete in the middle of the list. Since I reference the strings by their
  639. > index, I have to keep updating a separate list of defines that map to the
  640. > strings. (a BIG pain!!!)
  641. > Is there a better way to reference the strings?
  642.  
  643. There are two solutions to this problem. I have used both:
  644.    1. When you delete a string, replace it with an empty string and
  645. abandon the slot.
  646.    2. Use an enum instead of a list of defines. Deleting a symbol from the
  647. enum automatically adjusts the values of the others.
  648.  
  649. > What are the benefits of keeping the strings in the resources fork rather than
  650. > in the code itself? Is the string only loaded into memory when
  651. referenced, thus
  652. > saving memory space by keeping the strings in the resource fork? Or is it
  653. > simply to allow the strings to be modified without rebuilding the app?
  654.  
  655. The usual reason is to facilitate localization (translation) to another
  656. language. Any string that can be viewed by the user should be in a
  657. resource. That way translation can be done without access to the source
  658. code.
  659.  
  660. It also opens up ways for sophisticated users to do interesting hacks :)
  661.  
  662. - --------------------
  663. Ed Anson            MediaTree: multimedia outline editor & catalog
  664. Tulip Software
  665. Andover, MA 01810   For details, check out my WWW page:
  666. U.S.A.              <http://www.tiac.net/users/tulip/home.html>
  667.  
  668. +++++++++++++++++++++++++++
  669.  
  670. >From shopsinm@interport.net (shopsinm)
  671. Date: 7 Sep 1995 01:50:40 GMT
  672. Organization: Quill Program
  673.  
  674. In article <42ktiu$k4d@prospero.dev.cdx.mot.com>, Peter Kjersgard <petek> wrote:
  675.  
  676. >The app I am writing has 100+ error messages to display to the user. I
  677. >carefully typed them into a STR# resource for the app. Sometimes I have to
  678. >add/delete in the middle of the list. Since I reference the strings by their
  679. >index, I have to keep updating a separate list of defines that map to the
  680. >strings. (a BIG pain!!!)
  681. >
  682. >Is there a better way to reference the strings?
  683. >
  684. >What are the benefits of keeping the strings in the resources fork rather than
  685. >in the code itself? Is the string only loaded into memory when referenced, thus
  686. >saving memory space by keeping the strings in the resource fork? Or is it
  687. >simply to allow the strings to be modified without rebuilding the app?
  688.  
  689. I have a slightly dumber way of storing error strings that might help
  690. you.  For my code I store each error as a STR resource.  This means that
  691. if I eliminate some code I just delete the error strings and place new
  692. ones.  The only problem with my sceme is that a very large program (i.e.
  693. 500+ resources) would become very slow because each of my errors is a
  694. seperate resource.  I don't save my error strings in code because I might
  695. have to change them later.  I don't want to dig through everything &
  696. recompile just to fix a spelling error.
  697.  
  698.    Mike
  699.  
  700. -- 
  701. Michael Falk Shopsin
  702. shopsinm@interport.net
  703.  
  704. "If it's not on fire then it's a software problem."
  705.  
  706. +++++++++++++++++++++++++++
  707.  
  708. >From Darren Giles <mars@netcom.com>
  709. Date: Thu, 7 Sep 1995 08:59:05 GMT
  710. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  711.  
  712. In article <42ktiu$k4d@prospero.dev.cdx.mot.com> Peter Kjersgard, petek
  713. writes:
  714. >What are the benefits of keeping the strings in the resources fork rather than
  715. >in the code itself
  716.  
  717. Among other things, if you're going to do a fat application, this
  718. prevents you
  719. from having two copies of the strings.  Add up all the strings in your app
  720. that can be put into resources, and you may find this to be a substantial
  721. savings.
  722.  
  723. - Darren
  724.  
  725. ==========================================================================
  726. Darren Giles, Technical Director                           mars@netcom.com
  727. Terran Interactive                               http://www.terran-int.com
  728.  
  729. +++++++++++++++++++++++++++
  730.  
  731. >From DaveZ@mailbag.com (David B. Zwiefelhofer)
  732. Date: Thu, 07 Sep 1995 11:34:24 -0500
  733. Organization: Utility Reduction Specialists, Inc.
  734.  
  735. In article <shopsinm-0609952154450001@shopsinm.port.net>,
  736. shopsinm@interport.net (shopsinm) wrote:
  737.  
  738. > In article <42ktiu$k4d@prospero.dev.cdx.mot.com>, Peter Kjersgard
  739. <petek> wrote:
  740. > >The app I am writing has 100+ error messages to display to the user. I
  741. > >carefully typed them into a STR# resource for the app. Sometimes I have to
  742. > >add/delete in the middle of the list. Since I reference the strings by their
  743. > >index, I have to keep updating a separate list of defines that map to the
  744. > >strings. (a BIG pain!!!)
  745. > >
  746. > >Is there a better way to reference the strings?
  747. > >
  748. > >What are the benefits of keeping the strings in the resources fork
  749. rather than
  750. > >in the code itself? Is the string only loaded into memory when
  751. referenced, thus
  752. > >saving memory space by keeping the strings in the resource fork? Or is it
  753. > >simply to allow the strings to be modified without rebuilding the app?
  754. > I have a slightly dumber way of storing error strings that might help
  755. > you.  For my code I store each error as a STR resource.  This means that
  756. > if I eliminate some code I just delete the error strings and place new
  757. > ones.  The only problem with my sceme is that a very large program (i.e.
  758. > 500+ resources) would become very slow because each of my errors is a
  759. > seperate resource.  I don't save my error strings in code because I might
  760. > have to change them later.  I don't want to dig through everything &
  761. > recompile just to fix a spelling error.
  762.  
  763. Personally, I think your way is much better. As far as your program being
  764. slower I really doubt it. I mean how often do you need to access error
  765. messages? Surely no faster than is humanly possible to read them, right?
  766. The other advantage is that it is possible that GetIndString will have to
  767. read in a 32K resource (that's right, the entire STR# resource) just to
  768. access your 50 byte message whereas GetString will only use 50 bytes.
  769.  
  770. Dave
  771.  
  772. -- 
  773. David B. Zwiefelhofer
  774. Utility Reduction Specialists, Inc.
  775. 1605 Monroe Street, Suite 110
  776. Madison, WI  53211-2052
  777. (608) 258-8965
  778. (608) 258-9686 FAX
  779.  
  780. +++++++++++++++++++++++++++
  781.  
  782. >From tom@jlc.com (Thomas R. Kimpton)
  783. Date: Tue, 12 Sep 1995 15:06:25 -0600
  784. Organization: Jostens Learning Corporation
  785.  
  786. In article <42ktiu$k4d@prospero.dev.cdx.mot.com>, Peter Kjersgard <petek> wrote:
  787.  
  788. > The app I am writing has 100+ error messages to display to the user. I
  789. > carefully typed them into a STR# resource for the app. Sometimes I have to
  790. > add/delete in the middle of the list. Since I reference the strings by their
  791. > index, I have to keep updating a separate list of defines that map to the
  792. > strings. (a BIG pain!!!)
  793. > Is there a better way to reference the strings?
  794. [stuff deleted]
  795.  
  796. #define myErrorStr1     1
  797. #define myErrorStr2     (myErrorStr1 + 1)
  798. #define myErrorStr3     (myErrorStr2 + 1)
  799. ...
  800.  
  801. If you delete(insert after) the define of myErrorStr2 you need only change the
  802. define for myErrorStr3, and the effect ripples down.  Though this has the
  803. side effect that it's hard to know what the define actually is when
  804. looking at it in code.
  805.  
  806. Tom.
  807.  
  808. -- 
  809. Tom Kimpton                 tom@jlc.com
  810. Jostens Learning Corporation
  811. (801) 223-3228
  812.  
  813. +++++++++++++++++++++++++++
  814.  
  815. >From gurgle@apple.com (Pete Gontier)
  816. Date: Tue, 12 Sep 1995 17:52:24 -0800
  817. Organization: Apple Computer, Inc.
  818.  
  819. In article <tom-1209951506250001@tommac.wicat.com>,
  820. tom@jlc.com (Thomas R. Kimpton) wrote:
  821.  
  822.  > In article <42ktiu$k4d@prospero.dev.cdx.mot.com>,
  823.  > Peter Kjersgard <petek> wrote:
  824.  > 
  825.  > > The app I am writing has 100+ error messages to display to the user. I
  826.  > > carefully typed them into a STR# resource for the app. Sometimes I have to
  827.  > > add/delete in the middle of the list. Since I reference the strings by 
  828.  > > their index, I have to keep updating a separate list of defines that
  829.  > > map to the strings. (a BIG pain!!!)
  830.  >
  831.  > #define myErrorStr1     1
  832.  > #define myErrorStr2     (myErrorStr1 + 1)
  833.  > #define myErrorStr3     (myErrorStr2 + 1)
  834.  
  835. enum
  836. {
  837.    kStrIndex_Error_None,
  838.    kStrIndex_Error_FileNotFound,
  839.    kStrIndex_Error_MemoryExhausted,
  840.    kStrIndex_Error_DogcowEnraged
  841. };
  842.  
  843. If the SubSpace Manager ever ships, you won't have to worry about running
  844. out of memory any more, so you can just triple-click
  845. 'kStrIndex_Error_MemoryExhausted' and hit the delete key and all other
  846. values will ripple up. (We will never be able to eliminate the possibility
  847. of the last error in the list.)
  848.  
  849. -- 
  850.  Pete Gontier // Software reenignE
  851.  Macintosh Developer Technical Support // Apple Computer, Inc.
  852.  
  853. +++++++++++++++++++++++++++
  854.  
  855. >From stk@berlin.snafu.de (Stefan Kurth)
  856. Date: Wed, 13 Sep 1995 04:27:43 +0200
  857. Organization: none
  858.  
  859. Thomas R. Kimpton <tom@jlc.com> wrote:
  860.  
  861. > #define myErrorStr1     1
  862. > #define myErrorStr2     (myErrorStr1 + 1)
  863. > #define myErrorStr3     (myErrorStr2 + 1)
  864. > ...
  865. >
  866. > If you delete(insert after) the define of myErrorStr2 you need only change the
  867. > define for myErrorStr3, and the effect ripples down.
  868.  
  869.  
  870. Hmm, I think I would prefer
  871.  
  872. enum {
  873.    myErrorStr1,
  874.    myErrorStr2,
  875.    myErrorStr3,
  876.    ...
  877. };
  878.  
  879. Too bad that this can't be used in files that are included from both C
  880. and Rez.
  881.  
  882.  
  883. ________________________________________________________________________
  884. Stefan Kurth               Berlin, Germany           stk@berlin.snafu.de
  885.  
  886. +++++++++++++++++++++++++++
  887.  
  888. >From Kevin.R.Boyce@gsfc.nasa.gov (Kevin R. Boyce)
  889. Date: Thu, 14 Sep 1995 13:48:36 -0400
  890. Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA
  891.  
  892. In article <gurgle-1209951752240001@mac999.kip.apple.com>,
  893.  gurgle@apple.com (Pete Gontier) wrote:
  894.  
  895. >enum
  896. >{
  897. >   kStrIndex_Error_None,
  898. >   kStrIndex_Error_FileNotFound,
  899. >   kStrIndex_Error_MemoryExhausted,
  900. >   kStrIndex_Error_DogcowEnraged
  901. >};
  902. >
  903. >If the SubSpace Manager ever ships, you won't have to worry about running
  904. >out of memory any more, so you can just triple-click
  905. >'kStrIndex_Error_MemoryExhausted' and hit the delete key and all other
  906. >values will ripple up. (We will never be able to eliminate the possibility
  907. >of the last error in the list.)
  908.  
  909. Well sure, but why bother with an error message in that case.  Has
  910. *anybody* ever been in the same room with an enraged dogcow and lived to
  911. tell about it?
  912.  
  913. Otherwise, good advice.  I use enums for all my menu item definitions,
  914. too.  Then, as my menus grow ever-longer from version to version, I can
  915. just stick in the new items and they renumber automatically.
  916. -- 
  917. Kevin           Kevin.R.Boyce@gsfc.nasa.gov
  918. "You make a grown man cry."  --Mick Jagger
  919.  
  920. ---------------------------
  921.  
  922. >From Free Library Users <wicomico@shore.intercom.net>
  923. Subject: How do I change the mouse tracking speed?
  924. Date: 12 Sep 1995 18:38:08 GMT
  925. Organization: ICNet, Salisbury, MD
  926.  
  927. Hi
  928.  
  929. Do you know how the Mouse control panel does its thing?  Does it do some 
  930. shady manipulation of a secret system global inconspicuously lurking in 
  931. PRAM?  Or is the answer right under my nose?  If you know the answer or 
  932. know how I could find it, I would be most appreciative of any and all 
  933. suggestions.  Thanks.
  934.  
  935. Seth Purcell, Mac C++ Programmer for Soliton Software
  936.  
  937.  
  938. +++++++++++++++++++++++++++
  939.  
  940. >From tim@dierks.org (Tim Dierks)
  941. Date: Tue, 12 Sep 1995 23:21:21 +0100
  942. Organization: Best Internet Communications
  943.  
  944. In article <434k2g$69@shore4.intercom.net>, Free Library Users
  945. <wicomico@shore.intercom.net> wrote:
  946. >Do you know how the Mouse control panel does its thing?  Does it do some 
  947. >shady manipulation of a secret system global inconspicuously lurking in 
  948. >PRAM?  Or is the answer right under my nose?  If you know the answer or 
  949. >know how I could find it, I would be most appreciative of any and all 
  950. >suggestions.  Thanks.
  951.  
  952. Check out the Cursor Device Manager, documented in tech note HW 01:
  953.  
  954. <url:http://www.info.apple.com/dev/technotes/Hardware/hw_01.html>
  955.  
  956. (by yours truly). The speed is also stored in PRAM and it's done in low
  957. memory if you don't have the CDM. I don't have any info on that with me
  958. right now.
  959.  
  960. Best,
  961.  - Tim Dierks
  962.  
  963. -- 
  964. Tim Dierks
  965. tim@dierks.org
  966.  
  967. ---------------------------
  968.  
  969. >From timmyd@netcom.com (Tim DeBenedictis)
  970. Subject: How to disable entire menu bar?
  971. Date: Sun, 10 Sep 1995 00:32:31 GMT
  972. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  973.  
  974. I'm writing a generic routine for handling movable modal dialogs.  Everything
  975. works fairly well now, but I need some way to disable the entire menu bar,
  976. as ModalDialog() does when it starts up, and then to re-enable the entire
  977. menu bar when it exits.  Additionally, my function should be smart enough 
  978. to keep the Edit menu active when the movable modal dialog is frontmost. If 
  979. anyone out there knows how to do this, or could point me to some sample 
  980. code, I'd appreciate it!
  981.  
  982. -Tim DeBenedictis
  983. timmyd@netcom.com
  984.  
  985.  
  986. +++++++++++++++++++++++++++
  987.  
  988. >From gurgle@apple.com (Pete Gontier)
  989. Date: Tue, 12 Sep 1995 17:31:54 -0800
  990. Organization: Apple Computer, Inc.
  991.  
  992. In article <timmydDEnyu7.B5z@netcom.com>,
  993. timmyd@netcom.com (Tim DeBenedictis) wrote:
  994.  
  995.  > I'm writing a generic routine for handling movable modal dialogs. Everything
  996.  > works fairly well now, but I need some way to disable the entire menu bar,
  997.  > as ModalDialog() does when it starts up, and then to re-enable the entire
  998.  > menu bar when it exits.  Additionally, my function should be smart enough 
  999.  > to keep the Edit menu active when the movable modal dialog is frontmost.
  1000.  
  1001. Disabling the menu bar is easy. Just don't call MenuSelect. :-)
  1002.  
  1003. Seriously, though, the structures you would need to do something to a menu
  1004. bar directly are quasi-documented (see Inside Mac: Mac Toolbox Essentials
  1005. 3-97 for the usual warnings about such things). What you need to do to be
  1006. clean is keep track of which menus your app has inserted into the menu bar
  1007. so you can call...
  1008.  
  1009.    DisableItem (menuH, 0);
  1010.  
  1011. ...on each one. Since you are tracking these menus, you can pick and
  1012. choose which ones to selectively leave enabled.
  1013.  
  1014. -- 
  1015.  Pete Gontier // Software reenignE
  1016.  Macintosh Developer Technical Support // Apple Computer, Inc.
  1017.  
  1018. ---------------------------
  1019.  
  1020. >From poy@ecn.purdue.edu (Alfred L. Poy)
  1021. Subject: How to do continuous sound recording
  1022. Date: Mon, 11 Sep 1995 16:19:22 -0600
  1023. Organization: Purdue University
  1024.  
  1025. I'm trying to figure out how to do continuous sound recording.  What I
  1026. want to do is continuously record a sound and then have access to the
  1027. sound data which has already been recorded.  I've looked at Apple
  1028. source code examples, and while they show how to do double-buffered
  1029. playback, they don't show how to do some kind of double-buffered
  1030. recording.  There is always a skip in recording samples while the
  1031. code gears up to call SPRecord again (and play the sound too).
  1032. So, how does one accomplish this?  Is it possible to create a routine
  1033. which will automatically switch between recording buffers when one
  1034. is full?  Also, can this be implemented as an interrupt routine so
  1035. that I can do other tasks in the foreground without having to babysit
  1036. the process?
  1037.  
  1038. On a related note, I'm trying to implement some FFT routines which
  1039. could possibly steal several ticks-worth of processing time.  How
  1040. would it affect any other interrupt routines if I steal all the cycles?
  1041. (What I'm trying to say is I would also like to implement the FFT
  1042. routine as an interrupt process as well, to make it "automatic" in
  1043. conjunction with the recording process.  So can an interrupt routine
  1044. itself be interrupted by other interrupt routines?)
  1045.  
  1046. Thanks in advance for your help.
  1047.  
  1048. Al Poy
  1049. Purdue University       poy@ecn.purdue.edu
  1050.  
  1051. +++++++++++++++++++++++++++
  1052.  
  1053. >From dan@apple-iss.iss.nus.sg (Daniel Lau)
  1054. Date: Wed, 13 Sep 1995 08:12:32 +0800
  1055. Organization: Apple-ISS Research Centre
  1056.  
  1057. In article <poy-1109951619220001@192.0.2.1>, poy@ecn.purdue.edu (Alfred L.
  1058. Poy) wrote:
  1059.  
  1060. > I'm trying to figure out how to do continuous sound recording.  What I
  1061. > want to do is continuously record a sound and then have access to the
  1062. > sound data which has already been recorded.  I've looked at Apple
  1063. > source code examples, and while they show how to do double-buffered
  1064. > playback, they don't show how to do some kind of double-buffered
  1065. > recording.  There is always a skip in recording samples while the
  1066. > code gears up to call SPRecord again (and play the sound too).
  1067. > So, how does one accomplish this?  Is it possible to create a routine
  1068. > which will automatically switch between recording buffers when one
  1069. > is full?  Also, can this be implemented as an interrupt routine so
  1070. > that I can do other tasks in the foreground without having to babysit
  1071. > the process?
  1072.  
  1073. You can use the SPBRecord() call to do this.  The trick in doing continuous
  1074. recording is in the way you set up the sound parameter block.  Try this bit
  1075. of code (I've left out error-checking for brevity):
  1076.  
  1077. SPB    gSPB;
  1078. long   gRefNum;
  1079.  
  1080. void
  1081. StartContinuousRecording()
  1082. {
  1083.    // Open the default audio input device  
  1084.    SPBOpenDevice( nil, siWritePermission, &gRefNum );
  1085.  
  1086.     // You might want to set up some characteristics of the audio device
  1087. here ie.
  1088.     // sampling rate, size etc.
  1089.  
  1090.     gSPB.inRefNum          = gRefNum; // Reference to audio input device
  1091.     gmSPB.count            = 0;       // Unused for continuous recording
  1092.     gSPB.milliseconds      = 0;       // Unused for continuous recording
  1093.     gSPB.bufferLength      = 0;       // Unused for continuous recording
  1094.     gSPB.bufferPtr         = nil;     // Making this nil allows recording
  1095. to continue indefinitely
  1096.     gSPB.completionRoutine = nil;     // No completion routine needed.
  1097.     gSPB.interruptRoutine  = NewSIInterruptProc( InterruptHandler );
  1098.     gSPB.userLong          = 0L;      // Or whatever you want
  1099.  
  1100.     // True for async recording, false for synchronous
  1101.     SPBRecord( &gSPB, true );
  1102. }
  1103.  
  1104. Declare an interrupt handler
  1105.  
  1106.     void InterruptHandler( Ptr deviceBuffer, long deviceBufferSize );
  1107.  
  1108. to grab samples from the audio input device's buffer and save it to your
  1109. own (big) buffer.
  1110.  
  1111. > On a related note, I'm trying to implement some FFT routines which
  1112. > could possibly steal several ticks-worth of processing time.  How
  1113. > would it affect any other interrupt routines if I steal all the cycles?
  1114. > (What I'm trying to say is I would also like to implement the FFT
  1115. > routine as an interrupt process as well, to make it "automatic" in
  1116. > conjunction with the recording process.  So can an interrupt routine
  1117. > itself be interrupted by other interrupt routines?)
  1118.  
  1119. You could have your interrupt handler call an FFT function when you've
  1120. grabbed enough
  1121. samples to work with.  I'm not sure how much time you have to play when
  1122. the audio input
  1123. device interrupts though.
  1124.  
  1125. > Thanks in advance for your help.
  1126. > Al Poy
  1127. > Purdue University       poy@ecn.purdue.edu
  1128.  
  1129. Cheers,
  1130. dan
  1131.  
  1132. +++++++++++++++++++++++++++
  1133.  
  1134. >From chris-b@cs.auckland.ac.nz (chris-b)
  1135. Date: Wed, 13 Sep 1995 15:42:37 +1200
  1136. Organization: HyperMedia Unit, Comp Sci, Auckland University
  1137.  
  1138. In article <poy-1109951619220001@192.0.2.1>, poy@ecn.purdue.edu (Alfred L.
  1139. Poy) wrote:
  1140.  
  1141. >I'm trying to figure out how to do continuous sound recording.  What I
  1142. >want to do is continuously record a sound and then have access to the
  1143. >sound data which has already been recorded.  I've looked at Apple
  1144. >source code examples, and while they show how to do double-buffered
  1145. >playback, they don't show how to do some kind of double-buffered
  1146. >recording.  There is always a skip in recording samples while the
  1147. >code gears up to call SPRecord again (and play the sound too).
  1148. >
  1149. >So, how does one accomplish this?  Is it possible to create a routine
  1150. >which will automatically switch between recording buffers when one
  1151. >is full?  Also, can this be implemented as an interrupt routine so
  1152. >that I can do other tasks in the foreground without having to babysit
  1153. >the process?
  1154. >
  1155. >On a related note, I'm trying to implement some FFT routines which
  1156. >could possibly steal several ticks-worth of processing time.  How
  1157. >would it affect any other interrupt routines if I steal all the cycles?
  1158. >(What I'm trying to say is I would also like to implement the FFT
  1159. >routine as an interrupt process as well, to make it "automatic" in
  1160. >conjunction with the recording process.  So can an interrupt routine
  1161. >itself be interrupted by other interrupt routines?)
  1162.  
  1163. You can do this - note in the SPB structure the "interruptRoutine" field.
  1164. This field can contain a UPP to a routine that is called when the Mac's
  1165. recording buffer is filled. You can get the size of this buffer by calling
  1166. the _SPBGetDeviceInfo trap with a siDeviceBufferInfo query. You'll also
  1167. probably need to use many other selectors with _SPBSetDeviceInfo trap to
  1168. set the sound input device up as you require.
  1169.  
  1170. This is all documented in IM-6 22-59 on ("Recording Sounds Directly From a
  1171. Device"). It's probably also in NIM-Sound (or similar).
  1172.  
  1173. I don't know if you will be able to do an FFT at interrupt time -
  1174. especially from an interrupt service routine.
  1175.  
  1176. What I did was call _SPBRecord with SPB.bufferPtr = nil. This causes the
  1177. recording to happen until you call _SPBStopRecording. I set up
  1178. SPB.interruptRoutine = NewSIInterruptProc(MyInterruptProc). So
  1179. MyInterruptProc gets called at the end of each buffer, I do a quick check
  1180. of the data and if it looks "interesting", I _BlockMove it into a linked
  1181. list of preallocated buffers using the interrupt savvy _Enqueue call.
  1182.  
  1183. You could possibly achieve the same thing using deferred tasks...
  1184.  
  1185. Email me for more info.
  1186.  
  1187. Chris B
  1188. - ---------------------------------------------------------------------
  1189. NewZealand:AucklandUniversity:ComputerScience:HyperMediaUnit:ChrisBurns
  1190. Internet: chris-b@cs.auckland.ac.nz
  1191. Phone:    +64 9 373-7599 x6194
  1192. Fax:      +64 9 373-7453                         Async, therefore I am.
  1193. - ---------------------------------------------------------------------
  1194.  
  1195. +++++++++++++++++++++++++++
  1196.  
  1197. >From fdrake@sunspot.tiac.net (Frank Drake)
  1198. Date: 13 Sep 1995 21:08:00 GMT
  1199. Organization: The Internet Access Company
  1200.  
  1201. In article <dan-1309950812330001@17.127.18.246> dan@apple-iss.iss.nus.sg (Daniel Lau) writes:
  1202. [Original message and code deleted]
  1203. >
  1204. > Declare an interrupt handler
  1205. >
  1206. >     void InterruptHandler( Ptr deviceBuffer, long deviceBufferSize );
  1207. >
  1208. > to grab samples from the audio input device's buffer and save it to your
  1209. > own (big) buffer.
  1210.  
  1211. I am accomplishing the same, except I am using the completion routine
  1212. and just starting the recording again. By setting the SoundManager 
  1213. parameter "siContinuous" to 1, I don't get the clicking. However, I am
  1214. concerned that this parameter/feature may not be supported on all Mac
  1215. sound devices. Can anyone say if I am safe using this or should I use
  1216. Dan's method and use an interrupt handler (to avoid the lost data and
  1217. clicking that you get when not in continuous mode)?
  1218.  
  1219. > > On a related note, I'm trying to implement some FFT routines which
  1220. > > could possibly steal several ticks-worth of processing time.  How
  1221. > > would it affect any other interrupt routines if I steal all the cycles?
  1222. > > (What I'm trying to say is I would also like to implement the FFT
  1223. > > routine as an interrupt process as well, to make it "automatic" in
  1224. > > conjunction with the recording process.  So can an interrupt routine
  1225. > > itself be interrupted by other interrupt routines?)
  1226. > > 
  1227.  
  1228. > You could have your interrupt handler call an FFT function when you've
  1229. > grabbed enough
  1230. > samples to work with.  I'm not sure how much time you have to play when
  1231. > the audio input
  1232. > device interrupts though.
  1233.  
  1234. I want a very similar result for my application, but I don't know that
  1235. you would want to do this during the interrupt. The biggest reason is
  1236. that you may not have enough data to make it worth your while. For example,
  1237. my mac gets interrupted after sampling 512 bytes of data (I have no idea
  1238. how this varies from mac to mac). At 22kHz, you are not getting a lot
  1239. of data in that time slice. Perhaps you should collect as much data
  1240. as you need for your first FFT, set a flag, and then, back in your
  1241. app, do the FFT when that flag is set. I'm not really familiar with the
  1242. ins and outs of how you should do things on the mac, but I think you'd
  1243. do some polling OUTSIDE your interrupt routine (say, in your programs
  1244. event handler?) rather than risking life and limb by doing an FFT during
  1245. a SoundManager interrupt.
  1246.  
  1247. I'd love to hear some other opinions, though!!! I'm really new to the
  1248. Mac and I'm still trying to get a grasp on the way to do some of these
  1249. things.
  1250.  
  1251. Frank Drake (fdrake@tiac.net)
  1252. -- 
  1253. Frank Drake                 "Jesus saves - and Esposito scores on the rebound!"
  1254. InterACTics, Inc.                                          Tel: +1-617-674-0050
  1255. 420 Bedford Street, Suite 265                              FAX: +1-617-674-0125
  1256. Lexington, Massachusetts 02173  USA                   Internet: fdrake@tiac.net
  1257.  
  1258. +++++++++++++++++++++++++++
  1259.  
  1260. >From nic@crl.com (Guy Nicholas)
  1261. Date: 14 Sep 1995 04:19:49 GMT
  1262. Organization: CRL Dialup Internet Access
  1263.  
  1264. > I want a very similar result for my application, but I don't know that
  1265. > you would want to do this during the interrupt. The biggest reason is
  1266. > that you may not have enough data to make it worth your while. For example,
  1267. > my mac gets interrupted after sampling 512 bytes of data (I have no idea
  1268. > how this varies from mac to mac). At 22kHz, you are not getting a lot
  1269. > of data in that time slice. Perhaps you should collect as much data
  1270. > as you need for your first FFT, set a flag, and then, back in your
  1271. > app, do the FFT when that flag is set. I'm not really familiar with the
  1272. > ins and outs of how you should do things on the mac, but I think you'd
  1273.  
  1274. I understand that another problem with extended "direct to disk" recording
  1275. is that most hard drives have a thermal adjustment feature.  This means
  1276. they recalibrate themselves ever so often due to the disk
  1277. growing/shrinking with temperature changes.  In order to do this they move
  1278. the head somewhere and read or write or something, which interrupts the
  1279. steady flow of data.  I also understand some drivers have a feature to
  1280. lock this recalibration out but you can only hold it off for so long.
  1281.  
  1282. Guy
  1283.  
  1284. +++++++++++++++++++++++++++
  1285.  
  1286. >From poy@ecn.purdue.edu (Alfred L. Poy)
  1287. Date: Thu, 14 Sep 1995 10:21:15 -0600
  1288. Organization: Purdue University
  1289.  
  1290. In article <FDRAKE.95Sep13170800@sunspot.tiac.net>,
  1291. fdrake@sunspot.tiac.net (Frank Drake) wrote:
  1292.  
  1293. >>> (What I'm trying to say is I would also like to implement the FFT
  1294. >>> routine as an interrupt process as well, to make it "automatic" in
  1295. > I want a very similar result for my application, but I don't know that
  1296. > you would want to do this during the interrupt. The biggest reason is
  1297. > that you may not have enough data to make it worth your while. For example,
  1298. > my mac gets interrupted after sampling 512 bytes of data (I have no idea
  1299. > how this varies from mac to mac). At 22kHz, you are not getting a lot
  1300. > of data in that time slice.
  1301.  
  1302. After thinking it over for a while, I think you're right.  Since I'd
  1303. like to have 4096 bytes worth of data, I'll have to collect it up
  1304. until I have enough.  I'm going to first implement the FFT outside of an
  1305. interrupt routine.  When I get it working, I might attempt to go through
  1306. the Deferred Task Manager to have it done somewhat "automatically", as
  1307. Chris-b suggested.
  1308.  
  1309. Al Poy
  1310. Purdue University       poy@ecn.purdue.edu
  1311.  
  1312. ---------------------------
  1313.  
  1314. >From chouser@flair13 (Chris Houser)
  1315. Subject: How to receive an "open" message...
  1316. Date: 4 Sep 95 21:02:04 -0500
  1317. Organization: (none)
  1318.  
  1319. Hello...  I've got a program that is currently launching and running
  1320. correctly.  I recently added the ability to save and recall files, but I
  1321. would like to do this automatically the way a good Mac program should
  1322. (i.e. open the file that is double-clicked on in the finder).
  1323.  
  1324. Should I be handling this in my event lop somehow, or is it generally
  1325. done some other way...  Please help me! I've been unable to find any
  1326. sample code that contains this...
  1327.  
  1328. --Chris Houser
  1329. chouser@css.tayloru.edu
  1330.  
  1331. +++++++++++++++++++++++++++
  1332.  
  1333. >From ntoge@netcom.com (Nobukazu Toge)
  1334. Date: Tue, 5 Sep 1995 11:23:47 GMT
  1335. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1336.  
  1337. Chris Houser (chouser@flair13) wrote:
  1338. > Hello...  I've got a program that is currently launching and running
  1339. > correctly.  I recently added the ability to save and recall files, but I
  1340. > would like to do this automatically the way a good Mac program should
  1341. > (i.e. open the file that is double-clicked on in the finder).
  1342.  
  1343. First, make sure that your app is flagged "high-level event aware".
  1344.  
  1345. Then within your event loop, call AEProcessAppleEvent() if the acquired
  1346. event->what is kHighLevelEvent. Then AEProcess... calls AppleEvent handler
  1347. procs that are to be installed prior to starting the event loop.
  1348. This AEProcessAppleEvent() --> handler dispatching is automatic.
  1349.  
  1350. What you need to do is, somewhere right after initializing the Mac toolbox
  1351. you have to define and install your own adequate AE handler routines with
  1352. AEInstallEventHandler() proc. From within those handler routines
  1353. you do whatever needs to be done, i.e. open a file, print its content, 
  1354. etc. Usually a bulk content of such routines can be shared with those
  1355. that you'd use for regular actions in response to menu-selections, etc.
  1356.  
  1357. So, there won't be much new conding to do, but there are some details
  1358. to follow as to exactly how to retrieve the message content of AppleEvents.
  1359. Those things are not overwhelming, but a bit too long for here.
  1360.  
  1361. Books like Dave Mark's "Ultimate Mac Programming" gives the steps to follow.
  1362. If you have a CodeWarrior CD, it has the sample codes fromthis book
  1363. and others.
  1364.  --
  1365. Nobu Toge
  1366.      Internet: ntoge@netcom.com     AppleLink:      n.toge
  1367.      AOL     : ntoge                CompuServe:     76334,650           
  1368. #include <StandardDisclaimers.h>
  1369.  
  1370. +++++++++++++++++++++++++++
  1371.  
  1372. >From reed@medicine.wustl.edu (Thomas Reed)
  1373. Date: Wed, 06 Sep 1995 08:00:43 -0500
  1374. Organization: Washington University
  1375.  
  1376. >Should I be handling this in my event lop somehow, or is it generally
  1377. >done some other way...
  1378.  
  1379. Yes, you need to be using AppleEvents -- if your program is a System 7
  1380. program.  If you want to support System 6 or both System 6 AND System 7,
  1381. then you can do something else, although if you're trying to support both
  1382. systems, you should support both ways to do an open.
  1383.  
  1384. These days, none of my programs still support System 6, so I'm not as
  1385. familiar with that method as I was.  But, you can check out CountAppFiles
  1386. in Inside Macintosh -- according to the copy of THINK Reference I've got
  1387. in front of me, it's in the Segment Loader.
  1388.  
  1389. For AppleEvents, here's what you need to do.  First, you need to make sure
  1390. that the isHighLevelEventAware flag in the SIZE resource of your program
  1391. is set.
  1392.  
  1393. Second, you need to handle the kHighLevelEvent event type, like this:
  1394.  
  1395. void HandleEvent(EventRecord *event)
  1396. {
  1397.   switch (event->what)
  1398.   {
  1399.     case mouseDown:
  1400.       HandleMouseDown(event);
  1401.       break;
  1402.  
  1403. //  [...]
  1404.  
  1405.     case kHighLevelEvent:
  1406.       HandleAppleEvent(event);
  1407.       break;
  1408.   }
  1409. }
  1410.  
  1411. >From my code, HandleAppleEvent looks like this:
  1412.  
  1413. void HandleAppleEvent(EventRecord *event)
  1414. {
  1415.   OSErr  myErr;
  1416.  
  1417.   myErr = AEProcessAppleEvent(event);
  1418.   if (myErr)
  1419.     DeathAlert(errProcessAE, myErr);
  1420. }
  1421.  
  1422. ...where DeathAlert is just a custom error handler in my program.  This is
  1423. all there is to handling an AppleEvent -- sort of.  AEProcessAppleEvent
  1424. will process the event and determine what kind it is, then look in the
  1425. current application's AppleEvent handler table and jump to the appropriate
  1426. function.  So, you need to set up a handler table, like this:
  1427.  
  1428.    gOAPPHandler = NewAEEventHandlerProc(MyHandleOAPP);
  1429.    gODOCHandler = NewAEEventHandlerProc(MyHandleODOC);
  1430.    gPDOCHandler = NewAEEventHandlerProc(MyHandlePDOC);
  1431.    gQUITHandler = NewAEEventHandlerProc(MyHandleQUIT);
  1432.    
  1433.   myErr = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
  1434. gOAPPHandler, 0, FALSE);
  1435.   if (myErr != noErr)
  1436.    DeathAlert(errInstallAE, myErr);
  1437.  
  1438.   myErr = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
  1439. gODOCHandler, 0, FALSE);
  1440.   if (myErr != noErr)
  1441.    DeathAlert(errInstallAE, myErr);
  1442.  
  1443.   myErr = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
  1444. gPDOCHandler, 0, FALSE);
  1445.   if (myErr != noErr)
  1446.    DeathAlert(errInstallAE, myErr);
  1447.  
  1448.   myErr = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
  1449. gQUITHandler, 0, FALSE);
  1450.   if (myErr != noErr)
  1451.    DeathAlert(errInstallAE, myErr);
  1452.  
  1453. ...where the gXXXXHandler globals are declared as AEEventHandlerUPP.
  1454.  
  1455. So, then the code (from my program) for the handler programs looks like this:
  1456.  
  1457. static pascal OSErr MyHandleOAPP(AppleEvent *theAppleEvent, AppleEvent
  1458. *reply, long handlerRefcon)
  1459. {
  1460. /* do nothing */
  1461.   return noErr;
  1462. }
  1463.  
  1464. static pascal OSErr MyHandleODOC(AppleEvent *theAppleEvent, AppleEvent
  1465. *reply, long handlerRefcon)
  1466. {
  1467.    FSSpec   myFSS;
  1468.    AEDescList  docList;
  1469.    OSErr myErr;
  1470.    long  index, itemsInList;
  1471.    Size  actualSize;
  1472.    AEKeyword   keywd;
  1473.    DescType returnedType;
  1474.  
  1475.    // get the direct parameter--a descriptor list--and put
  1476.    // it into docList
  1477.    myErr = AEGetParamDesc(theAppleEvent, keyDirectObject,
  1478.                      typeAEList, &docList);
  1479.    if (myErr)
  1480.       DeathAlert(errParamDescAE, myErr);
  1481.  
  1482.    // check for missing required parameters
  1483.    myErr = GotRequiredParams(theAppleEvent);
  1484.    if (myErr) {
  1485.       // an error occurred:  do the necessary error handling
  1486.       myErr = AEDisposeDesc(&docList);
  1487.       return   myErr;
  1488.    }
  1489.  
  1490.    // now get first descriptor record from the list, coerce
  1491.    // the returned data to an FSSpec record, and open the
  1492.    // associated file
  1493.    // notice that I only call this once -- my program only opens one
  1494.    // file at a time.  You'd need to call this with an index to open
  1495.    // multiple files.
  1496.   myErr = AEGetNthPtr(&docList, 1, typeFSS, &keywd, &returnedType,
  1497. (Ptr)&myFSS, sizeof(myFSS), &actualSize);
  1498.   if (myErr)
  1499.       DeathAlert(errNthPtrAE, myErr);
  1500.       
  1501.    OpenDocument(&myFSS);
  1502.  
  1503.    myErr = AEDisposeDesc(&docList);
  1504.  
  1505.    return   noErr;
  1506. }
  1507.  
  1508. static pascal OSErr MyHandlePDOC(AppleEvent *theAppleEvent, AppleEvent
  1509. *reply, long handlerRefcon)
  1510. {
  1511. /* do nothing */
  1512.   return noErr;
  1513. }
  1514.  
  1515. static pascal OSErr MyHandleQUIT(AppleEvent *theAppleEvent, AppleEvent
  1516. *reply, long handlerRefcon)
  1517. {
  1518.   OSErr     myErr;
  1519.   
  1520.   myErr = GotRequiredParams(theAppleEvent);
  1521.   
  1522.   if (myErr != noErr)
  1523.     DeathAlert(errParamsAE, myErr);
  1524.   
  1525.   gQuit = TRUE;
  1526.   return noErr;
  1527. }
  1528.  
  1529. Hope this helps!
  1530.  
  1531. -Thomas
  1532.  
  1533. =====================================================
  1534. Thomas Reed                     Washington University
  1535. reed@visar.wustl.edu               Medical School
  1536. reed@medicine.wustl.edu            Saint Louis, MO
  1537. http://medinfo.wustl.edu/~reed
  1538. - ---------------------------------------------------
  1539. Clothes make the man.  Naked people have little or no
  1540. influence on society.  -- Mark Twain
  1541. =====================================================
  1542.  
  1543. Opinions posted are not the opinions of Wash. U.
  1544.  
  1545.  
  1546. ---------------------------
  1547.  
  1548. >From jgrass@cs.umass.edu (Joshua Grass)
  1549. Subject: Mac game programming web page
  1550. Date: 14 Sep 1995 17:13:38 GMT
  1551. Organization: University of Massachussetts Computer Science Department
  1552.  
  1553. Well, I have been spending a large protion of my free time this week
  1554. creating a web-page that I think will help a great deal of game
  1555. programmers.  It is called a HIT(Hierarchical Information Tree)
  1556. and it is a collection of cgi-scripts, forms and a simple database
  1557. that I hope will be the successor to FAQ's.  It is a databse of
  1558. information that novices and experts can add to.  Novices can ask
  1559. questions and experts can check a list of unanswered questions to
  1560. see if they can help.  What makes it so useful is the fact that
  1561. users of the system also create a tree of sub-categories that make
  1562. navigation easy.  Please come and check it out and let me know
  1563. what you think.  The web address is:
  1564.  
  1565. http://anytime.cs.umass.edu/~jgrass/MGPW/index.html
  1566.  
  1567.                                                 Joshua
  1568. -- 
  1569. If you want to know who you are,        | jgrass@cs.umass.edu
  1570. it's important to know who you've been. | http://anytime.cs.umass.edu/~jgrass
  1571.  
  1572.  
  1573. ---------------------------
  1574.  
  1575. >From mozart@coos.dartmouth.edu (Michael J. Fromberger)
  1576. Subject: Patching _Launch redux
  1577. Date: 6 Sep 1995 16:47:48 GMT
  1578. Organization: Dartmouth College, Hanover, NH, USA
  1579.  
  1580. Hello there,
  1581.  
  1582. Many thanks to the kind souls who provided me with copious wisdom on
  1583. the subject of how to patch the _Launch trap.  Thanks to your
  1584. assistance, I've been able to successfully complete my current
  1585. project.
  1586.  
  1587. For those who might be interested, here is a summary of useful tips:
  1588.  
  1589. - The Process Manager installs its own version of the _Launch trap after
  1590.   the INIT's and CDEV's are done loading.  This means you can't just
  1591.   patch it at INIT time, you have to load something that will do the
  1592.   patch -after- the Process Manager gets done toying with things.
  1593.  
  1594. - One good trick is to patch a -different- trap, which is called after
  1595.   the Process Manager patches _Launch.  _InitGraf was suggested, but if
  1596.   you do this, you have to be careful to wait for the right time.
  1597.   _InitGraf is called by many extensions while they are loading, so you
  1598.   wait 'til the current application name becomes meaningful (something
  1599.   other than -1L)
  1600.  
  1601. - Another way of doing this would be to hook into the low-memory ProcPtr
  1602.   jGNEFilter, the GetNextEvent/WaitNextEvent filter.  This is actually
  1603.   the stunt I used.  This has its own disadvantages, but isn't bad.
  1604.  
  1605. If anyone's interested, you can have a copy of the source for the patch
  1606. I've written.  It's pretty ugly, and most of it's in assembly language,
  1607. but it works fairly well for what it's designed to do.  If you want a
  1608. copy, e-mail me <Michael.Fromberger@Dartmouth.EDU> and I'll fire a copy
  1609. your way.  I'm developing using Metrowerks CodeWarrior on a 68K.
  1610.  
  1611. Once again, gracious thanks to everyone who helped out!
  1612.  
  1613. Cheers,
  1614. -M
  1615.  
  1616. --
  1617. Michael J. Fromberger
  1618. Consultant, Postmaster Group, Academic Unix Group
  1619. Dartmouth College, Hanover, New Hampshire, USA
  1620. Sting@Dartmouth.EDU / mozart@coos.dartmouth.edu
  1621.  
  1622. It was on analytical algebraic topology of local Euclidean metrization
  1623. of infinitely differentiable Riemannian manifolds...Bozhe moj! This
  1624. I know...from nothing.          -Tom Lehrer
  1625.  
  1626. +++++++++++++++++++++++++++
  1627.  
  1628. >From gurgle@apple.com (Pete Gontier)
  1629. Date: Wed, 06 Sep 1995 12:09:48 -0800
  1630. Organization: Apple Computer, Inc.
  1631.  
  1632. In article <42kjbk$8th@dartvax.dartmouth.edu>,
  1633. mozart@coos.dartmouth.edu (Michael J. Fromberger) wrote:
  1634.  
  1635.  > - One good trick is to patch a -different- trap, which is called after
  1636.  >   the Process Manager patches _Launch.  _InitGraf was suggested, but if
  1637.  >   you do this, you have to be careful to wait for the right time.
  1638.  >   _InitGraf is called by many extensions while they are loading, so you
  1639.  >   wait 'til the current application name becomes meaningful (something
  1640.  >   other than -1L)
  1641.  
  1642. Careful. What you want to test is the length byte, the magic value of
  1643. which is not -1L but simply -1. I believe the byte immediately after the
  1644. length byte is used by the (informally supported) ShowINIT protocol, so
  1645. don't do a 32-bit comparison.
  1646.  
  1647. -- 
  1648.  Pete Gontier // Software reenignE
  1649.  Macintosh Developer Technical Support // Apple Computer, Inc.
  1650.  
  1651. +++++++++++++++++++++++++++
  1652.  
  1653. >From mozart@coos.dartmouth.edu (Michael J. Fromberger)
  1654. Date: 7 Sep 1995 15:00:16 GMT
  1655. Organization: Dartmouth College, Hanover, NH, USA
  1656.  
  1657. In <gurgle-0609951209480001@mac207.kip.apple.com> gurgle@apple.com (Pete Gontier) writes:
  1658.  
  1659. >Careful. What you want to test is the length byte, the magic value of
  1660. >which is not -1L but simply -1. I believe the byte immediately after the
  1661. >length byte is used by the (informally supported) ShowINIT protocol, so
  1662. >don't do a 32-bit comparison.
  1663.  
  1664. I stand corrected...thanks! :)
  1665.  
  1666. -M
  1667.  
  1668. --
  1669. Michael J. Fromberger
  1670. Consultant, Postmaster Group, Academic Unix Group
  1671. Dartmouth College, Hanover, New Hampshire, USA
  1672. Sting@Dartmouth.EDU / mozart@coos.dartmouth.edu
  1673.  
  1674. "Half of what he said meant something else,
  1675.  and the other half didn't mean anything at all!"
  1676.           -Tom Stoppard
  1677.  
  1678. +++++++++++++++++++++++++++
  1679.  
  1680. >From kluev@macsimum.gamma.ru (Kluev)
  1681. Date: Thu, 7 Sep 95 17:43:11 +0400
  1682. Organization: (none)
  1683.  
  1684. In article <42kjbk$8th@dartvax.dartmouth.edu>,
  1685. mozart@coos.dartmouth.edu (Michael J. Fromberger) wrote:
  1686.  
  1687. >Many thanks to the kind souls who provided me with copious wisdom on
  1688. >the subject of how to patch the _Launch trap.  Thanks to your
  1689. >assistance, I've been able to successfully complete my current
  1690. >project.
  1691. >
  1692. >For those who might be interested, here is a summary of useful tips:
  1693. >...
  1694. >- Another way of doing this would be to hook into the low-memory
  1695. ProcPtr
  1696. >  jGNEFilter, the GetNextEvent/WaitNextEvent filter.  This is actually
  1697. >  the stunt I used.  This has its own disadvantages, but isn't bad.
  1698.  
  1699. Be carefull, if you are patching Launch this way. Some inits showes
  1700. dialogs and cause gne-events to flow *before* process manager starts
  1701. its plaing. The example of such an init is "Cache Switch": if you
  1702. turn off processor cache on 040 computer next reboot you will see an
  1703. alert during init time. If you press the button in this alert using
  1704. mouse (not keyboard) gne will fired.
  1705.  
  1706. - --------------------------------------------------------------
  1707. Michael Kluev                            kluev@macsimum.gamma.ru
  1708. Physics Grad Student                        Macintosh Programmer
  1709. MACsimum Ltd.                                     Moscow, Russia
  1710. - --------------------------------------------------------------
  1711.  
  1712. +++++++++++++++++++++++++++
  1713.  
  1714. >From quinn@cs.uwa.edu.au (Quinn "The Eskimo!")
  1715. Date: Tue, 12 Sep 1995 14:52:16 +0800
  1716. Organization: Underemployed, and loving it!
  1717.  
  1718. In article <42kjbk$8th@dartvax.dartmouth.edu>, mozart@coos.dartmouth.edu
  1719. (Michael J. Fromberger) wrote:
  1720.  
  1721. >Many thanks to the kind souls who provided me with copious wisdom on
  1722. >the subject of how to patch the _Launch trap.  Thanks to your
  1723. >assistance, I've been able to successfully complete my current
  1724. >project.
  1725.  
  1726. The way I patched _Launch was to tail patch SetTrapAddress looking for
  1727. when the Process Manager patches the _Launch trap and then immediately
  1728. patch _Launch myself in the tail part of my tail patch.  Skanky (see guys,
  1729. I've been practising my American :) but it works.  Oh and be aware that
  1730. System 6 MultiFinder does not call _Launch to launch applications, instead
  1731. it calls _OSDispatch with some bizarro undocumented selector.
  1732.  
  1733. You can tell I've done this before too (-:
  1734.  
  1735. Share and Enjoy.
  1736. --
  1737. Quinn "The Eskimo!"      "That's it, take me to your secret government
  1738.                           labs and cut me into wafer thin sections."
  1739.  
  1740. ---------------------------
  1741.  
  1742. >From dtc@pixar.com (David Catmull)
  1743. Subject: Pathname generation code?
  1744. Date: 12 Sep 1995 15:35:17 GMT
  1745. Organization: Pixar
  1746.  
  1747. I'm looking for some code that will find the pathname of a file-
  1748. particularly something that will shorten the name if it's too long to fit
  1749. in a text box, like:
  1750.  
  1751. Disk:...:Folder:File
  1752.  
  1753. Please e-mail responses. Thanks in advance.
  1754.  
  1755. David Catmull
  1756. dtc@pixar.com
  1757.  
  1758. +++++++++++++++++++++++++++
  1759.  
  1760. >From shaper@scubed.com (Walter Korman)
  1761. Date: Wed, 13 Sep 1995 20:58:13 GMT
  1762. Organization: S-Cubed division of Maxwell Labs
  1763.  
  1764. In article <dtc-1209950836490001@pinky.pixar.com>, dtc@pixar.com (David
  1765. Catmull) wrote:
  1766.  
  1767. > I'm looking for some code that will find the pathname of a file-
  1768. > particularly something that will shorten the name if it's too long to fit
  1769. > in a text box, like:
  1770. > Disk:...:Folder:File
  1771.  
  1772. The ellipsis (...) you may need to do yourself; I'm not sure if my
  1773. suggestion contains a feature which will do that for you.
  1774.  
  1775. My suggestion, then, is to get the "MoreFiles 1.3" library.  It's written
  1776. by Apple DTS, and contains over 100 functions to work with files.  Things
  1777. you probably have wanted and not been able to find, like "NameFileSearch",
  1778. which will search an entire disk to find an FSSpec for a particular file,
  1779. given its name.
  1780.  
  1781. The MoreFiles library should be on Apple's FTP or web server somewhere.  I
  1782. ended up getting it from somewhere in Switzerland, if you can believe
  1783. that.
  1784.  
  1785. If you're using Eudora or can extract Binhex from your mail, I'll be happy
  1786. to mail you an archive of the complete MoreFiles library.  It includes a
  1787. reference application containing info on all of its functions.  Quite well
  1788. written, really.
  1789.  
  1790. Make sure you compile it with the new Universal Headers 2.1.  It won't
  1791. compile well with anything else.
  1792.  
  1793. Hope this helps!
  1794.  
  1795. ....................................................................
  1796. - Walter Korman     * * ** *** ***** ******** <-- Fibonacci Tribbles
  1797.   shaper@scubed.com
  1798.  
  1799. +++++++++++++++++++++++++++
  1800.  
  1801. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro)
  1802. Date: Thu, 14 Sep 1995 11:54:01 +1200
  1803. Organization: University of Waikato
  1804.  
  1805. In article <dtc-1209950836490001@pinky.pixar.com>, dtc@pixar.com (David
  1806. Catmull) wrote:
  1807.  
  1808. >I'm looking for some code that will find the pathname of a file-
  1809. >particularly something that will shorten the name if it's too long to fit
  1810. >in a text box, like:
  1811. >
  1812. >Disk:...:Folder:File
  1813.  
  1814. IM:Text -- the TruncString and TruncText routines.
  1815.  
  1816. ---------------------------
  1817.  
  1818. >From axel@simplex.nl (Axel Roest)
  1819. Subject: Three AppleScript Qs (Apple Events)
  1820. Date: Wed, 13 Sep 1995 15:12:01 +0200
  1821. Organization: AXEL Development
  1822.  
  1823. Hi
  1824. I have three trivial (but unresolvable) AppleScript questions:
  1825.  
  1826. 1)      I want to display a window with a status from the script, without having
  1827. to press the OK button. Something like a counter for example. I tried the
  1828. following:
  1829.              with timeout of 60 seconds
  1830.                       display dialog counter as string
  1831.              end timeout
  1832. but that waits until the user pressend the button.
  1833. At the moment I use a folder in the Finder to display the counter!
  1834.  
  1835. 2) I have read in MacTech (which I don't have at the moment) that it is
  1836. possible to receive events from other applications by type & creator.
  1837. Something like
  1838.       on <<event applsend>> fileList
  1839.         displayfiles(fileList)
  1840.       end <<event applsend>>
  1841.  
  1842. I can't find any reference to this in the AppleScript Language Guide or
  1843. other books I have on my shelf. Is there a document hidden somewhere on my
  1844. develop CD or Apple FTP site which explains this? 
  1845. What I want to do is give another list *back* to the application as a
  1846. result, but at the moment I can only return a number.
  1847.  
  1848. 3) I want to perform a task every minute or so. What I want is something
  1849. like this:
  1850.       repeat
  1851.         do task
  1852.         sleep 60 --seconds
  1853.       end repeat
  1854. I cannot find any reference to a sleep, wait, delay function that does
  1855. this. At the moment I count the number of ticks in a repeat loop, but that
  1856. is kind of cpu time consuming. Any other way to simulate a delay loop?
  1857.  
  1858.  
  1859. I hope any gifted programmer out there can give me some solutions!
  1860.  
  1861.  
  1862. Axel
  1863.  
  1864. ________________________
  1865. Axel M. Roest           | Macintosh developer & UNIX sysadmin
  1866. axel@simplex.nl         | 
  1867.  
  1868. +++++++++++++++++++++++++++
  1869.  
  1870. >From plsuh@econ.sas.upenn.edu (Paul L. Suh)
  1871. Date: Wed, 13 Sep 1995 23:04:46 -0400
  1872. Organization: UPenn Grad Econ
  1873.  
  1874. In article <AC7CA54196686A4D59@minerva.simplex.nl>, axel@simplex.nl (Axel
  1875. Roest) wrote:
  1876.  
  1877. >Hi
  1878. >I have three trivial (but unresolvable) AppleScript questions:
  1879. >
  1880. >1)      I want to display a window with a status from the script, without
  1881. having
  1882. >to press the OK button. Something like a counter for example. I tried the
  1883. >following:
  1884. >             with timeout of 60 seconds
  1885. >                      display dialog counter as string
  1886. >             end timeout
  1887. >but that waits until the user pressend the button.
  1888. >At the moment I use a folder in the Finder to display the counter!
  1889.  
  1890. That's actually not a bad way to do it on the cheap.  However, if you want
  1891. to display some sort of progress, there is an app called Progress Bar that
  1892. does precisely that: it puts up windows under AppleScript control that
  1893. have a progress bar and a couple of lines of text.  It's available at 
  1894.  
  1895. <ftp://gaea.kgs.ukans.edu//applescript/scriptableapps/ProgressBar.101.hqx>
  1896.  
  1897.  
  1898. >2) I have read in MacTech (which I don't have at the moment) that it is
  1899. >possible to receive events from other applications by type & creator.
  1900. >Something like
  1901. >      on <<event applsend>> fileList
  1902. >        displayfiles(fileList)
  1903. >      end <<event applsend>>
  1904. >
  1905. >I can't find any reference to this in the AppleScript Language Guide or
  1906. >other books I have on my shelf. Is there a document hidden somewhere on my
  1907. >develop CD or Apple FTP site which explains this? 
  1908. >What I want to do is give another list *back* to the application as a
  1909. >result, but at the moment I can only return a number.
  1910.  
  1911. I know exactly what you're talking about, and I looked in my books but I
  1912. can't find it either.  Try subscribing to the MacScrpt mailing list, a
  1913. very active and informative source for Mac scripting questions.  
  1914.  
  1915. >3) I want to perform a task every minute or so. What I want is something
  1916. >like this:
  1917. >      repeat
  1918. >        do task
  1919. >        sleep 60 --seconds
  1920. >      end repeat
  1921. >I cannot find any reference to a sleep, wait, delay function that does
  1922. >this. At the moment I count the number of ticks in a repeat loop, but that
  1923. >is kind of cpu time consuming. Any other way to simulate a delay loop?
  1924.  
  1925. This is exactly what idle handlers were invented for.   
  1926.  
  1927. on idle
  1928.     -- do stuff
  1929.  
  1930.     return 60   -- seconds until called again
  1931. end idle
  1932.  
  1933. Save your script as a stay-open application.  The OS will then call the
  1934. idle handler every 60 seconds until you quit.  
  1935.  
  1936.  
  1937. Hope this helps.  
  1938.  
  1939.  
  1940. --Paul
  1941.  
  1942. -- 
  1943. P |\   / S   University of Pennsylvania     /---------\
  1944.   | \ /      Graduate Economics             |/-------\|
  1945.   |  X                                      ||  . .  ||  My first Macintosh
  1946.   | / \      Paul L. Suh                    ||  \_/  ||  512K!
  1947.   |/   \ D   plsuh@econ.sas.upenn.edu       ||       ||
  1948.   +------ Q                                 |\-------/|
  1949.                                             |---------|
  1950.                                             |_________|
  1951.  
  1952. +++++++++++++++++++++++++++
  1953.  
  1954. >From jwbaxter@olympus.net (John W. Baxter)
  1955. Date: Thu, 14 Sep 1995 12:25:51 -0700
  1956. Organization: Internet for the Olympic Peninsula
  1957.  
  1958. In article <AC7CA54196686A4D59@minerva.simplex.nl>, axel@simplex.nl (Axel
  1959. Roest) wrote:
  1960.  
  1961. > Hi
  1962. > I have three trivial (but unresolvable) AppleScript questions:
  1963. > 1)      I want to display a window with a status from the script,
  1964. without having
  1965. > to press the OK button. Something like a counter for example. I tried the
  1966. > following:
  1967. >              with timeout of 60 seconds
  1968. >                       display dialog counter as string
  1969. >              end timeout
  1970. > but that waits until the user pressend the button.
  1971. > At the moment I use a folder in the Finder to display the counter!
  1972.  
  1973. Paul Suh has suggested Progress Bar...there is also a newer one without
  1974. the bar, called
  1975.    "Message Window".  Probably in the same directory (it *is* on gaea).
  1976.  
  1977. Look in
  1978.     ftp://gaea.kgs.ukans.edu//applescript/scriptableapps/
  1979.  
  1980. > 2) I have read in MacTech (which I don't have at the moment) that it is
  1981. > possible to receive events from other applications by type & creator.
  1982. > Something like
  1983. >       on <<event applsend>> fileList
  1984. >         displayfiles(fileList)
  1985. >       end <<event applsend>>
  1986. > I can't find any reference to this in the AppleScript Language Guide or
  1987. > other books I have on my shelf. Is there a document hidden somewhere on my
  1988. > develop CD or Apple FTP site which explains this? 
  1989. > What I want to do is give another list *back* to the application as a
  1990. > result, but at the moment I can only return a number.
  1991.  
  1992. There are a few brief words burried in the AppleScript Language Guide. 
  1993. The 8 characters after the one space after event (assuming you're using
  1994. the English dialect) are first the four-character event class, then the
  1995. four character event id.
  1996.  
  1997. Try this experiment:
  1998.  
  1999. on <<event aevtoapp>>
  2000.    -- the normally "naked" code for your script goes here
  2001. end
  2002.  
  2003. Because it knows about that event, AppleScript will rewrite the above when
  2004. you compile it:
  2005.  
  2006. on run
  2007.    -- the normally "naked" code for your script goes here
  2008. end run
  2009.  
  2010. The reverse experiment.  Compile and save the script (as a compiled script)
  2011.  
  2012. display dialog "just testing"
  2013.  
  2014. Quit the Script Editor.  Remove the display dialog scripting addition from
  2015. the Scripting Additions folder.
  2016.  
  2017. Start the script editor, and open your saved script (or just double click it).
  2018.  
  2019. Note that you get the generic on <<event...>> form for the display dialog.
  2020.  
  2021. Drop the scripting addition back into the Scripting Additions folder...it
  2022. can execute, and will be rewritten back to the "display dialog" form next
  2023. time it is compiled.
  2024.  
  2025. You can do similar tricks with <<class abcd>>, which creates a thing of
  2026. typeType (or 'type'), with the value 'abcd'.
  2027.  
  2028.   --John
  2029.  
  2030. -- 
  2031. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  2032.        Bill:  what have you done for me lately?
  2033.    jwbaxter@pt.olympus.net
  2034.  
  2035. ---------------------------
  2036.  
  2037. End of C.S.M.P. Digest
  2038. **********************
  2039.